﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using YJKArchUtils.Utils;

namespace YJKRevitDimensionText.OneKeyPlanDim.Utility
{
	public class CommonDirectionLocationComparer : IComparer<CommonDirectionLevelDimDataInfo>
	{
		public int Compare(CommonDirectionLevelDimDataInfo commonDirLevel1, CommonDirectionLevelDimDataInfo commonDirLevel2)
		{
			try
			{
				if (Geometry.LessThan(commonDirLevel1.CenterDimFirst.PtLocation.Y, commonDirLevel2.CenterDimFirst.PtLocation.Y))
				{
					return 1;
				}
				if (!Geometry.LessThan(commonDirLevel1.CenterDimFirst.PtLocation.Y, commonDirLevel2.CenterDimFirst.PtLocation.Y))
				{
					return -1;
				}
				if (Geometry.LessThan(commonDirLevel1.CenterDimFirst.PtLocation.X, commonDirLevel2.CenterDimFirst.PtLocation.X))
				{
					return 1;
				}
				if (!Geometry.LessThan(commonDirLevel1.CenterDimFirst.PtLocation.X, commonDirLevel2.CenterDimFirst.PtLocation.X))
				{
					return -1;
				}
			}
			catch
			{
			}
			return 0;
		}

		private XYZ m_ptLocation;
	}
}
